#include "judgescenedialog.h"
#include "ui_judgescenedialog.h"

JudgeSceneDialog::JudgeSceneDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::JudgeSceneDialog)
{
    ui->setupUi(this);
    setWindowTitle(tr("Judge the square"));
    connect(ui->okButton,SIGNAL(clicked()),this,SLOT(close()));
    connect(ui->okButton,SIGNAL(clicked()),this,SLOT(dataOperationType()));
    connect(ui->buttonGroup,SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(onButtonClicked(QAbstractButton*)));
}
void JudgeSceneDialog::receiveCreatSquare(int x_Value,int y_Value,int side_Length,int square_Number)
{
    squareXValue=x_Value;
    squareYValue=y_Value;
    squareSideLength=side_Length;
    squareNumber=square_Number;
    QString str_x=QString::number(squareXValue);
    QString str_y=QString::number(squareYValue);
    QString str_sl=QString::number(squareSideLength);
    QString str_num=QString::number(squareNumber+1);
    ui->aboveGroupBox->setTitle("Square No."+str_num+" argument:");
    ui->belowGroupBox->setTitle("Square No."+str_num+" is...?");
    ui->xValue->setText(str_x);
    ui->yValue->setText(str_y);
    ui->sideLength->setText(str_sl);
}
void JudgeSceneDialog::dataOperationType()
{
    emit judgeResult(operationType);
}
void JudgeSceneDialog::onButtonClicked(QAbstractButton *button)
{
    if(button==ui->foreRadioButton)
        operationType=1;
    else if(button==ui->backRadioButton)
        operationType=2;
    else if(button==ui->noneRadioButton)
            operationType=0;
}
JudgeSceneDialog::~JudgeSceneDialog()
{
    delete ui;
}
